<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>GBoxed</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GObject Reference Manual">
<link rel="up" href="rn01.html" title="API Reference">
<link rel="prev" href="gobject-Enumeration-and-Flag-Types.html" title="Enums and Flags">
<link rel="next" href="gobject-Generic-values.html" title="Generic Values">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="preface" href="pr01.html" title="Introduction">
<link rel="part" href="pt01.html" title="Part&#160;I.&#160;Concepts">
<link rel="chapter" href="chapter-intro.html" title="Background">
<link rel="chapter" href="chapter-gtype.html" title="The GLib Dynamic Type System">
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
<link rel="reference" href="rn01.html" title="API Reference">
<link rel="reference" href="rn02.html" title="Tools Reference">
<link rel="part" href="pt02.html" title="Part&#160;IV.&#160;Tutorial">
<link rel="chapter" href="howto-gobject.html" title="How to define and implement a new GObject">
<link rel="chapter" href="howto-interface.html" title="How to define and implement interfaces">
<link rel="chapter" href="howto-signals.html" title="How to create and use signals">
<link rel="part" href="pt03.html" title="Part&#160;V.&#160;Related Tools">
<link rel="chapter" href="tools-gob.html" title="GObject builder">
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of GObjects">
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
<link rel="chapter" href="tools-gtkdoc.html" title="Writing API docs">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gobject-Enumeration-and-Flag-Types.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GObject Reference Manual</th>
<td><a accesskey="n" href="gobject-Generic-values.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2884136" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2884373" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="gobject-Boxed-Types"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2884136"></a><span class="refentrytitle">GBoxed</span>
</h2>
<p>GBoxed &#8212; A mechanism to wrap opaque C structures registered by the type system</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib-object.h&gt;


<a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a>            (<a class="link" href="gobject-Boxed-Types.html#GBoxedCopyFunc">*GBoxedCopyFunc</a>)                   (<a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> boxed);
void                (<a class="link" href="gobject-Boxed-Types.html#GBoxedFreeFunc">*GBoxedFreeFunc</a>)                   (<a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> boxed);
<a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a>            <a class="link" href="gobject-Boxed-Types.html#g-boxed-copy">g_boxed_copy</a>                        (<a class="link" href="gobject-Type-Information.html#GType">GType</a> boxed_type,
                                                         <a
href="./../glib/glib/glib-Basic-Types.html#gconstpointer"
>gconstpointer</a> src_boxed);
void                <a class="link" href="gobject-Boxed-Types.html#g-boxed-free">g_boxed_free</a>                        (<a class="link" href="gobject-Type-Information.html#GType">GType</a> boxed_type,
                                                         <a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> boxed);
<a class="link" href="gobject-Type-Information.html#GType">GType</a>               <a class="link" href="gobject-Boxed-Types.html#g-boxed-type-register-static">g_boxed_type_register_static</a>        (const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name,
                                                         <a class="link" href="gobject-Boxed-Types.html#GBoxedCopyFunc">GBoxedCopyFunc</a> boxed_copy,
                                                         <a class="link" href="gobject-Boxed-Types.html#GBoxedFreeFunc">GBoxedFreeFunc</a> boxed_free);
<a class="link" href="gobject-Type-Information.html#GType">GType</a>               <a class="link" href="gobject-Boxed-Types.html#g-pointer-type-register-static">g_pointer_type_register_static</a>      (const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name);

#define             <a class="link" href="gobject-Boxed-Types.html#G-TYPE-HASH-TABLE:CAPS">G_TYPE_HASH_TABLE</a>
#define             <a class="link" href="gobject-Boxed-Types.html#G-TYPE-DATE:CAPS">G_TYPE_DATE</a>
#define             <a class="link" href="gobject-Boxed-Types.html#G-TYPE-GSTRING:CAPS">G_TYPE_GSTRING</a>
#define             <a class="link" href="gobject-Boxed-Types.html#G-TYPE-STRV:CAPS">G_TYPE_STRV</a>
#define             <a class="link" href="gobject-Boxed-Types.html#G-TYPE-REGEX:CAPS">G_TYPE_REGEX</a>
typedef             <a class="link" href="gobject-Boxed-Types.html#GStrv">GStrv</a>;


</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2884373"></a><h2>Description</h2>
<p>
GBoxed is a generic wrapper mechanism for arbitrary C structures. The only
thing the type system needs to know about the structures is how to copy and
free them, beyond that they are treated as opaque chunks of memory.
</p>
<p>
Boxed types are useful for simple value-holder structures like rectangles or
points. They can also be used for wrapping structures defined in non-GObject
based libraries.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2884398"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2884408"></a><h3>
<a name="GBoxedCopyFunc"></a>GBoxedCopyFunc ()</h3>
<a class="indexterm" name="id2884421"></a><pre class="programlisting"><a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a>            (*GBoxedCopyFunc)                   (<a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> boxed);</pre>
<p>
This function is provided by the user and should produce a copy of the passed
in boxed structure.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>boxed</code></em>&#160;:</span></p></td>
<td>  The boxed structure to be copied.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>The newly created copy of the boxed structure.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2884480"></a><h3>
<a name="GBoxedFreeFunc"></a>GBoxedFreeFunc ()</h3>
<a class="indexterm" name="id2884493"></a><pre class="programlisting">void                (*GBoxedFreeFunc)                   (<a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> boxed);</pre>
<p>
This function is provided by the user and should free the boxed
structure passed.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>boxed</code></em>&#160;:</span></p></td>
<td>The boxed structure to be freed.


</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2884542"></a><h3>
<a name="g-boxed-copy"></a>g_boxed_copy ()</h3>
<a class="indexterm" name="id2884554"></a><pre class="programlisting"><a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a>            g_boxed_copy                        (<a class="link" href="gobject-Type-Information.html#GType">GType</a> boxed_type,
                                                         <a
href="./../glib/glib/glib-Basic-Types.html#gconstpointer"
>gconstpointer</a> src_boxed);</pre>
<p>
Provide a copy of a boxed structure <em class="parameter"><code>src_boxed</code></em> which is of type <em class="parameter"><code>boxed_type</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>boxed_type</code></em>&#160;:</span></p></td>
<td>The type of <em class="parameter"><code>src_boxed</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_boxed</code></em>&#160;:</span></p></td>
<td> The boxed structure to be copied.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>   The newly created copy of the boxed structure.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2884653"></a><h3>
<a name="g-boxed-free"></a>g_boxed_free ()</h3>
<a class="indexterm" name="id2884666"></a><pre class="programlisting">void                g_boxed_free                        (<a class="link" href="gobject-Type-Information.html#GType">GType</a> boxed_type,
                                                         <a
href="./../glib/glib/glib-Basic-Types.html#gpointer"
>gpointer</a> boxed);</pre>
<p>
Free the boxed structure <em class="parameter"><code>boxed</code></em> which is of type <em class="parameter"><code>boxed_type</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>boxed_type</code></em>&#160;:</span></p></td>
<td>The type of <em class="parameter"><code>boxed</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>boxed</code></em>&#160;:</span></p></td>
<td>     The boxed structure to be freed.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2884752"></a><h3>
<a name="g-boxed-type-register-static"></a>g_boxed_type_register_static ()</h3>
<a class="indexterm" name="id2884766"></a><pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType">GType</a>               g_boxed_type_register_static        (const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name,
                                                         <a class="link" href="gobject-Boxed-Types.html#GBoxedCopyFunc">GBoxedCopyFunc</a> boxed_copy,
                                                         <a class="link" href="gobject-Boxed-Types.html#GBoxedFreeFunc">GBoxedFreeFunc</a> boxed_free);</pre>
<p>
This function creates a new <a class="link" href="gobject-Type-Information.html#G-TYPE-BOXED:CAPS"><code class="literal">G_TYPE_BOXED</code></a> derived type id for a new
boxed type with name <em class="parameter"><code>name</code></em>. Boxed type handling functions have to be
provided to copy and free opaque boxed structures of this type.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></p></td>
<td>Name of the new boxed type.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>boxed_copy</code></em>&#160;:</span></p></td>
<td>Boxed structure copy function.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>boxed_free</code></em>&#160;:</span></p></td>
<td>Boxed structure free function.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>New <a class="link" href="gobject-Type-Information.html#G-TYPE-BOXED:CAPS"><code class="literal">G_TYPE_BOXED</code></a> derived type id for <em class="parameter"><code>name</code></em>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2884905"></a><h3>
<a name="g-pointer-type-register-static"></a>g_pointer_type_register_static ()</h3>
<a class="indexterm" name="id2884919"></a><pre class="programlisting"><a class="link" href="gobject-Type-Information.html#GType">GType</a>               g_pointer_type_register_static      (const <a
href="./../glib/glib/glib-Basic-Types.html#gchar"
>gchar</a> *name);</pre>
<p>
Creates a new <a class="link" href="gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> derived type id for a new
pointer type with name <em class="parameter"><code>name</code></em>. 
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></p></td>
<td>the name of the new pointer type.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td>a new <a class="link" href="gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> derived type id for <em class="parameter"><code>name</code></em>.


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2885011"></a><h3>
<a name="G-TYPE-HASH-TABLE:CAPS"></a>G_TYPE_HASH_TABLE</h3>
<a class="indexterm" name="id2885027"></a><pre class="programlisting">#define	G_TYPE_HASH_TABLE	(g_hash_table_get_type ())
</pre>
<p>
The <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for a boxed type holding a <a
href="./../glib/glib/glib-Hash-Tables.html#GHashTable"
><span class="type">GHashTable</span></a> reference.
</p>
<p class="since">Since 2.10


</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2885067"></a><h3>
<a name="G-TYPE-DATE:CAPS"></a>G_TYPE_DATE</h3>
<a class="indexterm" name="id2885080"></a><pre class="programlisting">#define	G_TYPE_DATE	        (g_date_get_type ())
</pre>
<p>
The <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for <a
href="./../glib/glib/glib-Date-and-Time-Functions.html#GDate"
><span class="type">GDate</span></a>.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2885112"></a><h3>
<a name="G-TYPE-GSTRING:CAPS"></a>G_TYPE_GSTRING</h3>
<a class="indexterm" name="id2885125"></a><pre class="programlisting">#define	G_TYPE_GSTRING		(g_gstring_get_type ())
</pre>
<p>
The <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for <a
href="./../glib/glib/glib-Strings.html#GString"
><span class="type">GString</span></a>.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2885158"></a><h3>
<a name="G-TYPE-STRV:CAPS"></a>G_TYPE_STRV</h3>
<a class="indexterm" name="id2885173"></a><pre class="programlisting">#define	G_TYPE_STRV	        (g_strv_get_type ())
</pre>
<p>
The <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for a boxed type holding a <a
href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"
><code class="literal">NULL</code></a>-terminated array of strings.
</p>
<p>
The code fragments in the following example show the use of a property of
type <a class="link" href="gobject-Boxed-Types.html#G-TYPE-STRV:CAPS"><span class="type">G_TYPE_STRV</span></a> with <a class="link" href="gobject-The-Base-Object-Type.html#g-object-class-install-property"><code class="function">g_object_class_install_property()</code></a>, <a class="link" href="gobject-The-Base-Object-Type.html#g-object-set"><code class="function">g_object_set()</code></a>
and <a class="link" href="gobject-The-Base-Object-Type.html#g-object-get"><code class="function">g_object_get()</code></a>.
</p>
<div class="informalexample"><pre class="programlisting">
g_object_class_install_property (object_class,
                                 PROP_AUTHORS,
                                 g_param_spec_boxed ("authors",
                                                     _("Authors"),
                                                     _("List of authors"),
                                                     G_TYPE_STRV,
                                                     G_PARAM_READWRITE));


gchar *authors[] = { "Owen", "Tim", NULL };
g_object_set (obj, "authors", authors, NULL);


gchar *writers[];
g_object_get (obj, "authors", &amp;writers, NULL);
/* do something with writers */
g_strfreev (writers);
</pre></div>
<p class="since">Since 2.4


</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2885266"></a><h3>
<a name="G-TYPE-REGEX:CAPS"></a>G_TYPE_REGEX</h3>
<a class="indexterm" name="id2884015"></a><pre class="programlisting">#define	G_TYPE_REGEX		(g_regex_get_type ())
</pre>
<p>
The <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for a boxed type holding a <a
href="./../glib/glib/glib-Perl-compatible-regular-expressions.html#GRegex"
><span class="type">GRegex</span></a> reference.
</p>
<p class="since">Since 2.14


</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2884055"></a><h3>
<a name="GStrv"></a>GStrv</h3>
<a class="indexterm" name="id2884067"></a><pre class="programlisting">typedef gchar** GStrv;
</pre>
<p>
A C representable type name for <a class="link" href="gobject-Boxed-Types.html#G-TYPE-STRV:CAPS"><span class="type">G_TYPE_STRV</span></a>.
</p>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2884092"></a><h2>See Also</h2>
<p>
<a class="link" href="gobject-Standard-Parameter-and-Value-Types.html#GParamSpecBoxed"><span class="type">GParamSpecBoxed</span></a>, <a class="link" href="gobject-Standard-Parameter-and-Value-Types.html#g-param-spec-boxed"><code class="function">g_param_spec_boxed()</code></a>
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2885547"></a><div class="refsect2" lang="en"><a name="id2885548"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id2885549"></a></div>
</div>
</div>
</body>
</html>
